package uk.ac.ebi.microarray.expressionprofiler.ra.fs;

import java.util.List;

import javax.resource.ResourceException;

import org.apache.commons.vfs.FileContent;

public interface FileSystemConnection {

    /**
     * <P>Returns <code>FileContent</code> of the file.</P>
     * @param name File name, will be searched in the current directory.
     * @return <code>FileContent</code> of the file.
     * @see org.apache.commons.vfs.FileContent
     * @throws ResourceException
     */
    FileContent getFileContent(String name) throws ResourceException;

    /**
     * <p>Creates file and returns <code>FileContent</code> for it.</p>
     * @param relativeName File name, relative to the current directory.
     * @return <code>FileContent</code> of new file.
     * @see org.apache.commons.vfs.FileContent
     * @throws ResourceException
     */
    FileContent getNewFileContent(String relativeName) throws ResourceException;

    /**
     * <P>Lists subdirectories of the current one.</P>
     * @return List&lt;String&gt;, containing subdirectories names.
     * @throws ResourceException
     */
    List<String> listDirs() throws ResourceException;

    /**
     * <p>List subdirectoris of the current one matching directory name regular expression.</p>
     * @param regexp Directory name regular expression.
     * @return List&lt;String&gt;, containing subdirectories names.
     * @throws ResourceException
     */
    List<String> listDirs(String regexp) throws ResourceException;

    /**
     * Lists files in the current directory.
     * @return List&lt;String&gt;, containing files names.
     * @throws ResourceException
     */
    List<String> listFiles() throws ResourceException;

    /**
     * <p>Lists files in the current directory matching file name regular expression.</p>
     * @param regexp File name regular expression.
     * @return List&lt;String&gt;, containing files names.
     * @throws ResourceException
     */
    List<String> listFiles(String regexp) throws ResourceException;

    /**
     * <p>Changes the current directory.</p>
     * @param dir A subdirectory of the current one, or ".." to go one directory up.
     * @throws ResourceException
     */
    void changeDir(String dir) throws ResourceException;

    /**
     * <p>Tries to change the current directory.</p>
     * @param dir A subdirectory of the current one, or ".." to go one directory up.
     * @return <code>true</code> if directory was changed successfully.
     */
    boolean tryChangedir(String dir);

    /**
     * <p>Changes the current directory or checks whether tar file exists and can be used as directory, if specified directory does not exist.</p>
     * @param dir A subdirectory (tar file) in the current one, or ".." to go one directory up.
     * @throws ResourceException
     */
    void changeDirOrTar(String dir) throws ResourceException;

    /**
     * <p>Closes the file system connection.</p>
     * @throws ResourceException
     */
    void close() throws ResourceException;

}